package com.seven.listener;

import cn.hutool.core.util.ClassUtil;
import com.seven.Commons;
import org.springframework.boot.SpringApplicationRunListener;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;

/**
 * @Author seven
 * @Date 2020/5/6 16:37
 **/

public class HelloSpringApplicationRunListener
        implements SpringApplicationRunListener {
    @Override
    public void starting() {
        Commons.getClassNameAndMethod(HelloSpringApplicationRunListener.class,"starting");
    }

    @Override
    public void environmentPrepared(ConfigurableEnvironment environment) {
        System.out.println("系统名称："+environment.getSystemProperties().get("os.name"));
        Commons.getClassNameAndMethod(HelloSpringApplicationRunListener.class,"environmentPrepared");
    }

    @Override
    public void contextPrepared(ConfigurableApplicationContext context) {
        Commons.getClassNameAndMethod(HelloSpringApplicationRunListener.class,"contextPrepared");
    }

    @Override
    public void contextLoaded(ConfigurableApplicationContext context) {
        Commons.getClassNameAndMethod(HelloSpringApplicationRunListener.class,"contextLoaded");
    }

    @Override
    public void started(ConfigurableApplicationContext context) {
        Commons.getClassNameAndMethod(HelloSpringApplicationRunListener.class,"started");

    }

    @Override
    public void running(ConfigurableApplicationContext context) {
        Commons.getClassNameAndMethod(HelloSpringApplicationRunListener.class,"running");
    }

    @Override
    public void failed(ConfigurableApplicationContext context, Throwable exception) {
        Commons.getClassNameAndMethod(HelloSpringApplicationRunListener.class,"failed");
    }
}
